package com.dao;

import com.model.PermissionRoleResource;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public interface PermissionRoleResourceMapper {
    int deleteByPrimaryKey(Long id);

    int insert(PermissionRoleResource record);

    int insertBatch(@Param(value = "resourceIds") List<Long> resourceIds, @Param(value = "roleId") Long roleId);

    int insertSelective(PermissionRoleResource record);

    PermissionRoleResource selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(PermissionRoleResource record);

    int updateByPrimaryKey(PermissionRoleResource record);

    @Select("DELETE FROM permission_role_resource  WHERE ROLE_ID=#{roleId}")
    void deleteByRoleId(@Param("roleId") Long roleId);

/*    @Select("<script>" +
            " select distinct RESOURCE_ID from  permission_role_resource where ROLE_ID in <foreach item='roleId' index='index' collection='roleIdList' open='(' separator=',' close=')'> #{roleId} </foreach>" +
            "</script>")*/
    List<Long> selectResourceIdList(@Param("roleIdList") List<Long> roleIdList);
}